import express, { Request, Response } from "express"
import positionManage from "./memberMange/positionManage"
import userList from "./userManage/userList"
import { AccountContext } from "../../../context/AccountContext"
import { useCheckAndResponse } from "../../../utils/common"
import memberList from "./memberMange/memberList"

const personnelManageRouter = express.Router()

personnelManageRouter.use("/memberManage/positionManage", positionManage)
personnelManageRouter.use("/memberManage/memberList", memberList)

personnelManageRouter.use("/userManage/userList", userList)

personnelManageRouter.put("/upgradeAuthority", async (req: Request, res: Response) => {
  const userId = req.query.userId as unknown as number

  const result = await AccountContext.getInstance().upgradeAuthority(userId)

  useCheckAndResponse(res, result[0], "权限升级成功")
})
personnelManageRouter.put("/downgradeAuthority", async (req: Request, res: Response) => {
  const userId = req.query.userId as unknown as number

  const result = await AccountContext.getInstance().downgradeAuthority(userId)

  useCheckAndResponse(res, result[0], "权限降级成功")
})



export default personnelManageRouter